package com.xx.sg.controller;

import com.xx.sg.own.entity.Dept;
import com.xx.sg.own.service.DeptService;
import com.xx.sg.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dept")
@Tag(name = "部门信息Api", description = "部门信息Api")
public class DeptController {

    @Autowired
    private DeptService deptService;

    @GetMapping("/areaDeptList")
    @Operation(summary = "查询24部门", description = "查询24部门")
    public R areaDeptList() {
        List<Dept> list = deptService.selectAreaDeptList();
        R r = R.success(list);
        r.put("message", "成功");
        r.put("success", true);
        return r;
    }

    @GetMapping("searchDeptByPoint")
    @Operation(summary = "根据经纬度获取所属部门", description = "根据经纬度获取所属部门")
    public R searchDeptByPoint(@RequestParam Double longitude, @RequestParam Double latitude) {
        Dept dept = deptService.selectDeptByPoint(longitude, latitude);
        return R.success(dept);
    }
}
